<% layout('/layouts/default.html', {title: '活动评论管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('活动评论管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('kj:kjActivityComment:edit')){ %>
<!--					<a href="${ctx}/kj/kjActivityComment/form" class="btn btn-default btnTool" title="${text('新增活动评论')}"><i class="fa fa-plus"></i> ${text('新增')}</a>-->
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${kjActivityComment}" action="${ctx}/kj/kjActivityComment/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('城市')}：</label>
				<div class="control-inline">
					<#form:listselect id="citySelect" title="城市选择"
					labelPath="name"
					url="${ctx}/kj/kjCity/kjCitySelect?pageSize=1000" allowClear="false" callbackFuncName='cityselectCallback'
					checkbox="false" itemCode="id" itemName="name"/>
				</div>
			</div>
				<div class="form-group">
					<#form:hidden path="commentType" />
					<label class="control-label">${text('活动')}：</label>
					<div class="control-inline">
						<% if(kjActivityComment.commentType == 'ACTIVITY'){%>
						<#form:listselect id="activitySelect" title="活动选择"
						path="activityId"  labelPath="activityName"
						url="${ctx}/kj/kjActivity/kjActivitySelect" allowClear="false"
						checkbox="false" itemCode="id" itemName="name"/>
						<% }%>
						<% if(kjActivityComment.commentType == 'PROJECT'){%>
						<#form:listselect id="activitySelect" title="活动选择"
						path="activityId"  labelPath="activityName"
						url="${ctx}/kj/kjContributeProject/kjContributeProjectSelect" allowClear="false"
						checkbox="false" itemCode="id" itemName="name"/>
						<% }%>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审核状态')}：</label>
					<div class="control-inline width-120">
						<#form:select  path="processStatus" dictType="approve_status" blankOption="true" maxlength="1" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('用户')}：</label>
					<div class="control-inline">
						<#form:input path="memberName" autocomplete="off" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("活动名")}', name:'activityName', index:'a.activity_name', width:150, align:"left"},
		{header:'${text("评论内容")}', name:'content', index:'a.content', width:150, align:"left"},
		{header:'${text("用户名")}', name:'kjMember.name', index:'m.name', width:150, align:"left"},
		{header:'${text("评论时间")}', name:'commentTime', index:'a.comment_time', width:150, align:"center"},
		{header:'${text("城市")}', name:'kjActivity.kjCity.name', index:'ka.a.name', width:150, align:"center"},
		{header:'${text("审核状态")}', name:'processStatus', index:'a.process_status', width:150, align:"left", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('approve_status')}, val, '待审批', true);
			}},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('kj:kjActivityComment:edit')){ %>
				actions.push('<a href="${ctx}/kj/kjActivityComment/form?id='+row.id+'" class="btnList" title="${text("编辑活动评论")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				// actions.push('<a href="${ctx}/kj/kjActivityComment/delete?id='+row.id+'" class="btnList" title="${text("删除活动评论")}" data-confirm="${text("确认要删除该活动评论吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
				if (row.processStatus != '2'){
					actions.push('<a href="${ctx}/kj/kjActivityComment/disable?id='+row.id+'" class="btnList" title="${text("停用评论")}" data-confirm="${text("确认要停用该评论吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if(row.processStatus != '1'){
					actions.push('<a href="${ctx}/kj/kjActivityComment/enable?id='+row.id+'" class="btnList" title="${text("启用评论")}" data-confirm="${text("确认要启用该评论吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});
function cityselectCallback(id, act, index, layero, selectData){
	if (act === 'ok' || act === 'clear'){
		var win = layero.iframeWindow();
		log(win);    // 选择框内容的window对象
		log(act);    // 回调活动事件（ok、clear、cancel）
		log(index);  // layer的index
		log(layero); // layer实例对象
		log(selectData);// 选择的节点数据
		if(selectData[Object.keys(selectData)[0]]!==undefined){
	        $('#activitySelectDiv').attr('data-url', '/kj/a/kj/kjActivity/kjActivitySelect?kjCity.id=' + selectData[Object.keys(selectData)[0]].id);
		}else {
			$('#activitySelectDiv').attr('data-url', '/kj/a/kj/kjActivity/kjActivitySelect');
		}
	}
}
</script>
